import axios from 'axios'
export default value => {
  let path = `/api/book-content/${value}/`
  return axios.get(path)
    .then(response => {
      let chapterContent = {
        title: '',
        content: ''
      }
      let title = response.data
        .match(/<div class="title">+[^>]+[^<]+<\/div>/g, '')
        .join('')
        .replace(/<div class="title">/g, '')
        .replace(/<\/div>/g, '')
      let content = response.data
        .match(/<p>+[^>]+[^<]+<\/p>/g, '')
        .join('')
      chapterContent.title = title
      chapterContent.content = content
      return chapterContent
    })
}
